﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login_AdminLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Sharemp3DataContext db = new Sharemp3DataContext();
        string username = txtUsername.Text;
        string pass = txtPass.Text;
        try
        {
            UserLogin user = db.UserLogins.Where(i => i.Username == username && i.Password == pass && i.Role == 1).First<UserLogin>();          
            Session["Admin"] = user;
            Response.Redirect("Admin.aspx");
        }
        catch
        {
            lblResult.Text = "Username or password is invalid !";
        }
    }
}